import React from 'react'
import { useDispatch, useSelector } from 'react-redux'

//引入action
import { getMovieAction } from '../../store/slice/movieSlice'


export default function Movie() {

  const dispatch = useDispatch()

  const movieList= useSelector(state=>
      // console.log(state,'movie');
      state.movie.movieList
  )


  const getMovieHandle =()=>{
    dispatch(getMovieAction())
  }


  return (
    <div>
        <br />
        <h2>与count通讯，这里数字是【{}】</h2>
        <br />
        <h2>电影列表</h2>
        <button onClick={getMovieHandle}>点击获取电影信息</button>

        <ul>
        {
          movieList.map(item => {
            return <li key={item.tvId}>{item.albumName}</li>
          })
        }
      </ul>
    </div>
  )
}
